home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 8_5.lha / 8_5 / nstdio.h < prev    next >
Text File  |  1993-08-08  |  5KB  |  160 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / Exercise 8.5
  6. / <stdio.h>
  7. / Implementation of standard I/O
  8. / using the stream I/O functions.
  9. ifndef STDIO_H
  10. define STDIO_H
  11. include <stream.h>
  12. include <stdarg.h>
  13. undef FILE            /* DELETE */
  14. undef _bufend            /* DELETE */
  15. undef _bufsiz            /* DELETE */
  16. undef getc            /* DELETE */
  17. undef putc            /* DELETE */
  18. undef getchar            /* DELETE */
  19. undef putchar            /* DELETE */
  20. undef clearerr            /* DELETE */
  21. undef feof            /* DELETE */
  22. undef ferror            /* DELETE */
  23. undef fileno            /* DELETE */
  24. undef EOF            /* DELETE */
  25. undef NULL            /* DELETE */
  26. undef BUFSIZ            /* DELETE */
  27. undef stdin            /* DELETE */
  28. undef stdout            /* DELETE */
  29. undef stderr            /* DELETE */
  30. undef L_ctermid        /* DELETE */
  31. undef L_cuserid        /* DELETE */
  32. undef P_tmpdir            /* DELETE */
  33. undef L_tmpnam            /* DELETE */
  34. undef _NFILE            /* DELETE */
  35. undef _SBFSIZ            /* DELETE */
  36. undef _IOFBF            /* DELETE */
  37. undef _IOREAD            /* DELETE */
  38. undef _IOWRT            /* DELETE */
  39. undef _IONBF            /* DELETE */
  40. undef _IOMYBUF            /* DELETE */
  41. undef _IOEOF            /* DELETE */
  42. undef _IOERR            /* DELETE */
  43. undef _IOLBF            /* DELETE */
  44. undef _IORW            /* DELETE */
  45. define FILE xFILE        /* DELETE */
  46. define BUFSIZ xBUFSIZ        /* DELETE */
  47. define EOF xEOF        /* DELETE */
  48. define clearerr xclearerr    /* DELETE */
  49. define fclose xfclose        /* DELETE */
  50. define feof xfeof        /* DELETE */
  51. define ferror xferror        /* DELETE */
  52. define fflush xfflush        /* DELETE */
  53. define fgetc xfgetc        /* DELETE */
  54. define fgets xfgets        /* DELETE */
  55. define fileno xfileno        /* DELETE */
  56. define fopen xfopen        /* DELETE */
  57. define fprintf xfprintf    /* DELETE */
  58. define fputc xfputc        /* DELETE */
  59. define fputs xfputs        /* DELETE */
  60. define fread xfread        /* DELETE */
  61. define freopen xfreopen    /* DELETE */
  62. define fscanf xfscanf        /* DELETE */
  63. define fwrite xfwrite        /* DELETE */
  64. define getc xgetc        /* DELETE */
  65. define getchar xgetchar    /* DELETE */
  66. define gets xgets        /* DELETE */
  67. define printf xprintf        /* DELETE */
  68. define putc xputc        /* DELETE */
  69. define putchar xputchar    /* DELETE */
  70. define scanf xscanf        /* DELETE */
  71. define setbuf xsetbuf        /* DELETE */
  72. define sprintf xsprintf    /* DELETE */
  73. define sscanf xsscanf        /* DELETE */
  74. define stderr xstderr        /* DELETE */
  75. define stdin xstdin        /* DELETE */
  76. define stdout xstdout        /* DELETE */
  77. define ungetc xungetc        /* DELETE */
  78. define vfprintf xvfprintf    /* DELETE */
  79. define vfscanf xvfscanf    /* DELETE */
  80. define vprintf xvprintf    /* DELETE */
  81. define vscanf xvscanf        /* DELETE */
  82. define vsprintf xvsprintf    /* DELETE */
  83. define vsscanf xvsscanf    /* DELETE */
  84.  
  85. lass FILE
  86.  
  87.    open_mode mode;
  88.    union
  89. {
  90. istream *in;
  91. ostream *out;
  92. };
  93.    streambuf *sb;
  94.    char unbuf;
  95.  
  96. ublic:
  97.    FILE(streambuf *st, open_mode m);
  98.    FILE(istream *is);
  99.    FILE(ostream *os);
  100.    ~FILE();
  101.  
  102.    // open and close FILEs
  103.    friend FILE *fopen(const char *file,
  104. const char *mode);
  105.    friend FILE *freopen(const char *file,
  106. const char *mode, FILE *f);
  107.    friend int fclose(FILE *);
  108.  
  109.    // input functions
  110.    friend int getc(FILE *);
  111.    friend int ungetc(int const, FILE *);
  112.    friend int fgetc(FILE *);
  113.    friend int getchar();
  114.    friend char *gets(char *buf);
  115.    friend char *fgets(char *buf, int sz, FILE *);
  116.    friend int fread(void *buf, unsigned int sz,
  117. unsigned int n, FILE *);
  118.    friend int scanf(const char *fmt, ...);
  119.    friend int fscanf(FILE *, const char *fmt, ...);
  120.    friend int sscanf(const char *buf,
  121. const char *fmt, ...);
  122.    friend int vscanf(const char *fmt, va_list vl);
  123.    friend int vfscanf(FILE *f,
  124. const char *fmt, va_list vl);
  125.    friend int vsscanf(const char *str,
  126. const char *fmt, va_list vl);
  127.  
  128.    // output functions
  129.    friend int putc(int c, FILE *);
  130.    friend int putchar(int c);
  131.    friend int fputc(int c, FILE *);
  132.    friend int puts(const char *buf);
  133.    friend int fputs(const char *buf, FILE *);
  134.    friend int fwrite(void *buf, unsigned int sz,
  135. unsigned int n, FILE *);
  136.    friend int printf(const char *fmt, ...);
  137.    friend int fprintf(FILE *, const char *fmt, ...);
  138.    friend int sprintf(char *buf, const char *fmt, ...);
  139.    friend int vprintf(const char *fmt, va_list);
  140.    friend int vfprintf(FILE *,
  141. const char *fmt, va_list);
  142.    friend int vsprintf(char *buf,
  143. const char *fmt, va_list);
  144.  
  145.    // status manipulation and checking
  146.    friend int ferror(FILE *);
  147.    friend int feof(FILE *);
  148.    friend void clearerr(FILE *);
  149.  
  150.    // buffering manipulation
  151.    friend void setbuf(FILE *, char *);
  152.    friend int fflush(FILE *);
  153. ;
  154.  
  155. define NULL 0
  156. onst int EOF = -1;
  157. onst int BUFSIZ = 1024;
  158. xtern FILE *stdin, *stdout, *stderr;
  159. endif /* STDIO_H */
  160.